<?php

namespace App\Http\Controllers;

use App\Category;
use App\Novel;
use App\Type;
use Illuminate\Http\Request;

class IndexController extends Controller
{
    public function index(){
        $typeNovels=[];
        foreach (Type::get() as $item){

            $typeNovels[$item->name]=Novel::where('typeid',$item->id)->get();

        }
        return view('index.index',['recommentdList'=>Novel::where('recommend',1)->limit(6)->get(),
            'hots'=>Novel::orderBy('clicksum','desc')->limit(6)->get(),
            'typeNovels'=>$typeNovels
            ]);
    }
}
